Clamp default frequency grid to Nyquist for discrete diskmargin and mu#148
Merged
Conversation
`sim_diskmargin(L, σ, l, u)` and `structured_singular_value(M0::LTISystem)` both built their default frequency grid up to 1e3 rad/s. For discrete-time inputs whose Nyquist frequency π/Ts is below 1e3, that grid extended beyond Nyquist and `freqresp` aliased (`cis(ω·Ts)` is 2π/Ts-periodic), so the worst-case margin / μ computed on the default grid reflected an aliased frequency rather than the intended one. The MIMO branch of `diskmargin(L, σ; l, u)` is also fixed because it forwards to `sim_diskmargin`. Clamp the upper bound to `min(u, π/L.Ts)` (or `min(3.0, log10(π/M0.Ts))` in log-frequency) when the system is discrete. Continuous-time behavior is unchanged. Users who deliberately want frequencies past Nyquist can still pass an explicit `w` vector. Adds a regression test in `test/test_diskmargin.jl` using `Ts=1.0` (Nyquist ≈ 3.14 rad/s, well below the default 1e3) that confirms the default-grid result agrees with an explicit Nyquist-respecting grid and that the worst-case frequency is at or below Nyquist. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #148 +/- ##
==========================================
- Coverage 91.84% 91.78% -0.06%
==========================================
Files 20 20
Lines 3064 3066 +2
==========================================
Hits 2814 2814
- Misses 250 252 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sim_diskmargin(L, σ, l, u)andstructured_singular_value(M0::LTISystem)(no-wform) both used a default frequency grid up to 1e3 rad/s. For discrete-time inputs whose Nyquist π/Ts is below 1e3, the grid extended past Nyquist andfreqrespaliased (cis(ω·Ts)is 2π/Ts-periodic), so the worst-case margin / μ from the default grid reflected an aliased frequency rather than the intended one.min(u, π/L.Ts)when the system is discrete. The MIMO branch ofdiskmargin(L, σ; l, u)benefits automatically since it forwards tosim_diskmargin. Continuous-time behavior is unchanged. Users who deliberately want frequencies past Nyquist can still pass an explicitwvector.Test plan
test_diskmargin.jlwithTs=1.0(Nyquist ≈ 3.14 rad/s, well below the default 1e3): asserts the default-grid result agrees with an explicit Nyquist-respecting grid and that the worst-case frequency is at or below Nyquist.Ts=1e-3, Nyquist ≈ 3141 > 1e3) is unaffected because the clamp resolves tomin(1e3, 3141) = 1e3.🤖 Generated with Claude Code